#include <allegro.h>
#include <winalleg.h>
#include <alleggl.h>
#include <GL\glu.h>
#include <iostream>
#include <vector>

double* SplitQuad(double Quad[12], int size)
{
	if(size = 1)
	{
		return Quad;
	}
	double result[3*size*size + 6*size + 3];
	int i = 1;
	int j = 1;
	result[0] = Quad[0];
	result[1] = Quad[1];
	result[2] = Quad[2];
	result[3*size] = Quad[3];
	zesult[(3*size) + 1] = Quad[4];
	result[(3*size) + 2] = Quad[5];
	result[(3*size*size) + (3*size)] = Quad[6];
	result[(3*size*size) + (3*size) + 1] = Quad[7];
	result[(3*size*size) + (3*size) + 2] = Quad[8];
	result[(3*size*size) + (6*size)] = Quad[9];
	result[(3*size*size) + (6*size) + 1] = Quad[10];
	result[(3*size*size) + (6*size) + 2] = Quad[11];
	while(i<=size)
	{
		while(j<=size)
		{
			result[i*(3*size + 3)] = Quad[0];
			result[i*(3*size + 4)] = Quad[1]*i/size;
			result[i*(3*size + 5)] = Quad[2];
			j++;
		};
	}
}

int main(int argc, char** argv)
{
	int size;
	int dimension;

	cin>>size;
	cin>>dimension;

    allegro_init();
    install_allegro_gl();
    install_keyboard();

    glShadeModel(GL_SMOOTH);
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClearDepth(8.0f);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_NORMALIZE);
    glDepthFunc(GL_LEQUAL);
    allegro_gl_set(AGL_COLOR_DEPTH, 32);
    allegro_gl_set(AGL_Z_DEPTH, 8);
    allegro_gl_set(AGL_SUGGEST, AGL_COLOR_DEPTH | AGL_Z_DEPTH);
    set_gfx_mode(GFX_OPENGL_WINDOWED, 640, 480, 0, 0);
    glViewport(0, 0, 640, 480);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(10,-10,10,-10,10,-10);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    while(!key[KEY_ESC])
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0,0,-6);
                glBegin(GL_QUADS);

                glVertex3f(-1,1,-1);
                glVertex3f(1,1,-1);
                glVertex3f(1,-1,-1);
                glVertex3f(-1,-1,-1);

                glVertex3f(-1,1,-1);
                glVertex3f(-1,1,1);
                glVertex3f(1,1,1);
                glVertex3f(1,1,-1);

                glVertex3f(1,1,-1);
                glVertex3f(1,-1,-1);
                glVertex3f(1,1,1);
                glVertex3f(1,-1,1);

                glVertex3f(-1,1,-1);
                glVertex3f(-1,1,1);
                glVertex3f(-1,-1,-1);
                glVertex3f(-1,-1,1);

                glVertex3f(-1,1,1);
                glVertex3f(-1,-1,1);
                glVertex3f(1,1,1);
                glVertex3f(1,-1,1);

                glVertex3f(1,-1,-1);
                glVertex3f(1,-1,-1);
                glVertex3f(-1,-1,1);
                glVertex3f(-1,-1,1);

                glEnd();

                allegro_gl_flip();
    }
    allegro_exit();
    return 0;
}
END_OF_MAIN();
